package reflection;

import classUtils.User;
import org.springframework.util.ReflectionUtils;

import java.lang.reflect.Field;
import java.lang.reflect.Method;

/**
 * @program: pangu
 * @description:
 * @author: fengjd
 * @create: 2022-06-23 09:34
 **/
public class ReflectionUtilTest {
    public static void main(String[] args) {
        /* 获取方法 */
        Method getId = ReflectionUtils.findMethod(User.class, "getId");

        /* 获取字段 */
        Field id = ReflectionUtils.findField(User.class, "id");

        /* 执行方法 */
        /*ReflectionUtils.invokeMethod(getId,springContextsUtil) ;*/

        /*判断字段是否是常量*/
        boolean publicStaticFinal = ReflectionUtils.isPublicStaticFinal(id);
        System.out.println("publicStaticFinal = " + publicStaticFinal);

        /*判断是否equals方法*/
        Method getId1 = ReflectionUtils.findMethod(User.class, "getId");
        System.out.println("ReflectionUtils.isEqualsMethod(getId1) = " + ReflectionUtils.isEqualsMethod(getId1));

        /* 如果打印指定方法的所有参数，打印指定类的所有成员变量 */
    }
}
